# 使用官方 Python 3.10 镜像作为基础镜像
FROM python:3.10-slim

# 设置工作目录
WORKDIR /app

# 安装系统依赖
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    curl \
    wget \
    ffmpeg \
    unzip \
    git-lfs \
    sox \
    libsox-dev \
    nvidia-cuda-toolkit \
    && rm -rf /var/lib/apt/lists/*

# 初始化 git-lfs
RUN git lfs install

# 复制项目文件
COPY . /app/

# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com

# 安装 conda 和 pynini
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \
    && bash miniconda.sh -b -p /opt/conda \
    && rm miniconda.sh

ENV PATH="/opt/conda/bin:$PATH"

RUN conda install -y -c conda-forge pynini==2.1.5

# 创建必要的目录
RUN mkdir -p /app/pretrained_models /app/voices /app/audios

# 设置环境变量
ENV PYTHONPATH=/app
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7865

# 暴露端口
EXPOSE 7865

# 启动命令
CMD ["python", "webui.py", "--port", "7865", "--server-name", "0.0.0.0"] 